<?php
// 应用公共文件
function getGuid($key = '', $len = null) {
    $Guid = md5(uniqid($key, true) .
        mt_rand() .
        ($_SERVER['REMOTE_ADDR'] ?? '') .
        ($_SERVER['HTTP_USER_AGENT'] ?? '') .
        ($_SERVER['REMOTE_PORT'] ?? ''));
    if ($len !== null) {
        if ($len > 0) {
            $Guid = substr($Guid, 0, $len);
        } elseif ($len < 0) {
            $Guid = substr($Guid, $len);
        }
    }
    return $Guid;
}

function successMsg($msg,$data=null) {
    $result = array(
        'code' => 1,
        'msg' => $msg,
        'data' => $data
    );
    return $result;
}

function errorMsg($msg,$data=null) {
    $result = array(
        'code' => 0,
        'msg' => $msg,
        'data' => $data
    );
    return $result;        
}
?>